package com.aispeech.astools.utils;

import android.media.AudioFormat;

/**
 * @author rain  08.14 2018
 */

public class AudioRecordConfig {

    private int channel;
    private int source;
    private int encoding;
    private int ReadBufIntervalTime;
    private int onErrorTryNumber = 10;
    private String readBufferSavePath ;

    public String getReadBufferSavePath() {
        return readBufferSavePath;
    }

    public void setReadBufferSavePath(String readBufferSavePath) {
        this.readBufferSavePath = readBufferSavePath;
    }


    public int getOnErrorTryNumber() {
        return onErrorTryNumber;
    }

    public void setOnErrorTryNumber(int onErrorTryNumber) {
        this.onErrorTryNumber = onErrorTryNumber;
    }

    public int getChannelVal() {
        if (this.channel == AudioFormat.CHANNEL_IN_STEREO) {
            return 2;
        } else if (this.channel == AudioFormat.CHANNEL_IN_MONO) {
            return 1;
        }
        return 0;
    }



    public int getEncodingVal() {
        if (this.encoding == AudioFormat.ENCODING_PCM_16BIT) {
            return 16;
        } else if (this.encoding == AudioFormat.ENCODING_PCM_8BIT) {
            return 8;
        }
        return 0;
    }

    public int getSample() {
        return sample;
    }

    public void setSample(int sample) {
        this.sample = sample;
    }

    private int sample;

    public int getChannel() {
        return channel;
    }

    public void setChannel(int channel) {
        this.channel = channel;
    }

    public int getSource() {
        return source;
    }

    public void setSource(int source) {
        this.source = source;
    }

    public int getEncoding() {
        return encoding;
    }

    public void setEncoding(int encoding) {
        this.encoding = encoding;
    }

    public int getReadBufIntervalTime() {
        return ReadBufIntervalTime;
    }

    public void setReadBufIntervalTime(int readBufIntervalTime) {
        ReadBufIntervalTime = readBufIntervalTime;
    }

    @Override
    public String toString() {
        return "AudioRecordConfig{" +
            "channel=" + channel +
            ", source=" + source +
            ", encoding=" + encoding +
            ", ReadBufIntervalTime=" + ReadBufIntervalTime +
            ", sample=" + sample +
            '}';
    }
}
